import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProductAuthorizeVO, ProductAuthorizeForm, ProductAuthorizeQuery, authorizeAddForm } from '@/api/iot/productAuthorize/types';

/**
 * 查询产品授权码列表
 * @param query
 * @returns {*}
 */

export const listProductAuthorize = (query?: ProductAuthorizeQuery): AxiosPromise<ProductAuthorizeVO[]> => {
  return request({
    url: '/iot/productAuthorize/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询产品授权码详细
 * @param authorizeId
 */
export const getProductAuthorize = (authorizeId: string | number): AxiosPromise<ProductAuthorizeVO> => {
  return request({
    url: '/iot/productAuthorize/' + authorizeId,
    method: 'get'
  });
};

/**
 * 新增产品授权码
 * @param data
 */
export const addProductAuthorize = (data: ProductAuthorizeForm) => {
  return request({
    url: '/iot/productAuthorize',
    method: 'post',
    data: data
  });
};

/**
 * 生成产品授权码
 * @param data
 */
export const addProductAuthorize1 = (data: authorizeAddForm) => {
  return request({
    url: '/iot/productAuthorize/add1',
    method: 'post',
    data: data
  });
};

/**
 * 修改产品授权码
 * @param data
 */
export const updateProductAuthorize = (data: ProductAuthorizeForm) => {
  return request({
    url: '/iot/productAuthorize',
    method: 'put',
    data: data
  });
};

/**
 * 删除产品授权码
 * @param authorizeId
 */
export const delProductAuthorize = (authorizeId: string | number | Array<string | number>) => {
  return request({
    url: '/iot/productAuthorize/' + authorizeId,
    method: 'delete'
  });
};
